<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
	<title>Promise testDemo</title>
	<style type="text/css">
	* {
		padding: 0;
		margin: 0;
	}
	
</style>
</head>
<body>
	<h1>aaaa</h1>
</body>
<script src="index.js"></script>
<script type="text/javascript">

function load(file, resolve, reject) {
  const script = document.createElement("script");
  script.src = file;
  script.onload = resolve;
  script.onerror = reject;
  document.body.appendChild(script);
}


/*
load(
  "js/hd.js",
  script => {
  	console.log(script)
  	
    console.log(`${script.path[0].src} 加载成功`);
    hd();
  },
  error => {
    console.log(`${error.srcElement.src} 加载失败`);
  }
);

*/

load(
  "js/hd.js",
  script => {
  	// houdunren.js 依赖 hd.js，需要先加载hd.js 后加载houdunren.js
  	 load("js/houdunren.js", script=> {
  	 	houdunren()
  	 })
  },
  error => {
    console.log(`${error.srcElement.src} 加载失败`);
  }
);

</script>
</html>